function e(e, t, a) {
    return t in e ? Object.defineProperty(e, t, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = a, e;
}

var t = Object.assign || function(e) {
    for (var t = 1; t < arguments.length; t++) {
        var a = arguments[t];
        for (var i in a) Object.prototype.hasOwnProperty.call(a, i) && (e[i] = a[i]);
    }
    return e;
}, a = require("./variables");

Component({
    options: {
        multipleSlots: !0
    },
    properties: {
        appName: {
            type: String,
            value: "card"
        },
        remarkHint: {
            type: String,
            value: "让你的微信好友更了解你"
        },
        type: {
            type: String,
            value: a.TYPES.NORMAL_VERIFY
        },
        data: {
            type: Object,
            value: {},
            observer: function(e, a) {
                this.setData({
                    form: t({}, this.data.form, e)
                });
            }
        },
        fields: {
            type: Array,
            value: [ [ "user" ], [ "corpname", "position", "email" ], [ "remark" ] ]
        },
        validFilds: {
            type: Array,
            value: [ {
                keys: "realname",
                tip: "请输入名字"
            }, {
                keys: "corpname",
                tip: "请输入公司"
            }, {
                keys: "position",
                tip: "请输入职务"
            } ]
        },
        searchOrient: {
            type: String,
            value: a.ORIENT.BOTTOM
        },
        isVerifyCode: {
            type: Boolean,
            value: !0
        },
        isShownSendBtn: {
            type: Boolean,
            value: !0
        }
    },
    data: {
        TYPES: a.TYPES,
        form: {}
    },
    ready: function() {
        this.mobile = this.selectComponent("#mobile");
    },
    methods: {
        selectAvatar: function() {
            var e = this;
            wx.chooseImage({
                count: 1,
                sizeType: [ "compressed" ],
                success: function(t) {
                    var a = t.tempFilePaths[0];
                    e.setData({
                        "form.avatar": a
                    }), e.$emit("input", {
                        name: "avatar",
                        value: a
                    });
                }
            });
        },
        onInput: function(t) {
            var a = t.detail, i = a.name, n = a.value;
            this.setData(e({}, "form." + i, n)), this.$emit("input", {
                name: i,
                value: n
            });
        },
        onTextareaInput: function(e) {
            var t = e.currentTarget.dataset.name, a = e.detail.value;
            this.onInput({
                detail: {
                    name: t,
                    value: a
                }
            });
        },
        onFocusTextarea: function() {
            var e = this;
            this.setData({
                textareaShown: !0
            }), setTimeout(function() {
                e.setData({
                    textareaFocus: !0
                });
            }, 200);
        },
        onBlurTextarea: function() {
            this.setData({
                textareaShown: !1,
                textareaFocus: !1
            });
        },
        onSelect: function(t) {
            var a = t.detail, i = a.name, n = a.value;
            this.setData(e({}, "form." + i, n)), this.$emit("input", {
                name: i,
                value: n
            });
        },
        valideForm: function(e) {
            return this.data.validFilds.filter(function(t) {
                return !e["" + t.keys];
            }).map(function(e) {
                return e.tip;
            })[0];
        },
        getFormData: function() {
            var e = this.data.form, t = this.mobile.getFormData();
            if (t) {
                Object.assign(e, t);
                var a = this.valideForm(e);
                return a ? this.$emit("fail", {
                    value: a
                }) : e;
            }
        },
        onSearchOrient: function(t) {
            var i = this, n = t.detail.name, o = this.data.searchOrient === a.ORIENT.BOTTOM;
            o && wx.pageScrollTo({
                scrollTop: 0,
                duration: 0
            });
            var r = this.createSelectorQuery();
            r.select("#" + n).boundingClientRect(), r.selectViewport().scrollOffset(), r.exec(function(t) {
                var a = t[0].top, r = void 0;
                r = o ? "top: " + (a + 44) + "px; bottom: 0" : "bottom: " + (wx.getSystemInfoSync().windowHeight - a - 1) + "px; top: 0;", 
                i.setData(e({}, "searchList." + n, r));
            });
        },
        onMobileFail: function(e) {
            var t = e.detail.value;
            this.$emit("fail", {
                value: t
            });
        },
        onMobileInput: function(e) {
            var t = e.detail, a = t.name, i = t.value;
            this.$emit("input", {
                name: a,
                value: i
            });
        },
        onMobileClear: function(e) {
            var t = e.detail.name;
            this.$emit("clear", {
                name: t
            });
        },
        changeMobile: function() {
            wx.navigateTo({
                url: "/pages/changemobile/changemobile?mode=changeMobile"
            });
        },
        $emit: function(e, t) {
            this.triggerEvent(e, t, {});
        }
    }
});